package ii.zjf.student;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(StudentProperties.class)
@ConditionalOnProperty(
        prefix = "student",
        name = {"name","age"}
)
public class SutdentAutoConfig {

    @Bean(name = "student-demo")
    @ConditionalOnMissingBean
    Student student(StudentProperties properties) {
        return new Student(properties.getName(), properties.getAge());
    }

}
